#include "stdio.h"
typedef struct ListNode {
    int val;
    struct ListNode *next;
}ListNode;
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB)
{
    if(headA==NULL||headB==NULL)
        return NULL;
    ListNode *pA=headA;
    ListNode *pB=headB;

    while (pA!=pB)
    {
        if(pA==NULL)
            pA=headB;
        else
            pA=pA->next;
        if(pB==NULL)
            pB=headA;
        else
            pB=pB->next;
    }
    return pB;
}
